home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / HyperCuber 2.0 ƒ / HyperCuber Manual / HyperCuber Manual.rsrc / TEXT_136.txt < prev    next >
Text File  |  1994-05-03  |  5KB  |  92 lines

  1.  
  2. Object File Format
  3.  
  4. HyperCuber 2.0 is the first version of HyperCuber to support user-defined objects. The object file format is still very rough, and will certainly improve in the future. For the moment, it works, barely, and that‚Äôs something.
  5.  
  6. The format, in theory, supports three kinds of primitives: points, line segment paths, and polygons. An actuality, it supports only line segment paths. I wrote some code to draw the points and polygons, but I haven‚Äôt tested it, and it would be a miracle if it worked. I guarantee, in fact, that polygons do not obscure each other correctly, since there is absolutely no hidden line removal code in HyperCuber 2.0. So unless you‚Äôre daring or curious, stick to line segment paths.
  7.  
  8. A line segment path is just a list of points. When drawn, these points will be connected consecutively with line segments (all of the same color). So a square might be a list of five points: (0, 0), (1, 0), (1, 1), (0, 1), (0, 0). Note that HyperCuber does not automatically close the path; if you want a closed path you have to repeat the first point at the end.
  9.  
  10. HyperCuber is fairly fast, and part of this speed results from its policy of only projecting or rotating a point once. For instance, our square has two line segments connected to (0, 0), but HyperCuber only computes the projection or rotation of (0, 0) once, and uses the result to draw both line segments. HyperCuber does this by keeping a list of all the points in an object. Every time you refer to a point, you refer to it not by coordinates but by the index of that point into the vertices table. So if our vertices table were T[1] = (0, 0), T[2] = (1, 0), T[3] = (1, 1), T[4] = (0, 1), we could draw the square by connecting line segments in the order 1-2-3-4-1. HyperCuber looks up 1 in the table and sees that that‚Äôs really (0, 0) and uses those coordinates to draw it. If we want to rotate the square, we can just rotate each point in the table and the use the same 1-2-3-4-1 to draw. Note in particular that we don‚Äôt need to rotate point 1 twice, even though it‚Äôs referred to twice in the description.
  11.  
  12. HyperCuber uses this same sort of table setup for the colors; all colors to be used are defined at the beginning of the file and are referred to by index.
  13.  
  14. Below is the file format. Basically, an object file is a list of vertices used, followed by a list of colors used, followed by a list of primitives. Note that HyperCuber does not yet support comments in object files; the comments below are there only to describe the different parts of the file. For a specific example of an object file, see the Sample Object File chapter.
  15.  
  16. P.S.  If anyone makes some nifty objects, please mail them to me; I would love to see them, and I might even include them with the next release!
  17.  
  18. ============================ File format =============================
  19.  
  20.     1                                ; version number
  21.     d                                ; dimensions of the object (i.e. 4 for a 4D object)
  22.     0                                ; reserved (must be 0)
  23.     0                                ; reserved (must be 0)
  24.     n                                ; number of vertices
  25.     (x1, x2, ..., xn) ; vertices (coordinates)
  26.     (x1, x2, ..., xn)
  27.  
  28.         . . .
  29.  
  30.     (x1, x2, ..., xn)
  31.     c                               ; number of colors
  32.     r1, g1, b1                ; red/green/blue components of colors (each up to 16-bit)
  33.     r2, g2, b2
  34.  
  35.         . . .
  36.  
  37.     rc, gc, bc
  38.     m                               ; number of primitives
  39.     primitive 1
  40.     primitive 2
  41.  
  42.         . . .
  43.  
  44.     primitive m
  45.     [eof]                        ; end of file; don't actually type [eof]
  46.  
  47.  
  48. ========================= Primitives format =========================
  49.  
  50.     p                                       ; primitive type
  51.     primitive description    ;
  52.  
  53.  
  54. ================== Primitive Types and Descriptions ==================
  55.  
  56. Type 1: point
  57. Description:
  58.  
  59.     c                        ; color of point (index into color list)
  60.     p                        ; coordinates of point (index into vertex list)
  61.  
  62.  
  63. Type 2: line segment path
  64. Description:
  65.  
  66.     c                        ; color of line segment (index into color list)
  67.     n                        ; number of points in path
  68.     p1                    ; points in path (indices into vertex list)
  69.     p2
  70.     
  71.     ...
  72.     
  73.     pn                    ;  (note: pn is NOT automatically connected to p1)
  74.  
  75.  
  76. Type 3: filled polygon
  77. Description:
  78.  
  79.     ic                    ; color of interior of polygon (index into color list,
  80.         ;                               transparent if 0)
  81.     bc                    ; color of boundary of polygon (index into color list,
  82.         ;                               not drawn if 0)
  83.     n                        ; number of points in polygon
  84.     p1                    ; points in polygon (indices into vertex list)
  85.     p2
  86.     
  87.     ...
  88.     
  89.     pn                    ;  (note: pn is automatically connected to p1 to make
  90.         ;         polygon closed)
  91.     
  92.